/**
 * Copyright:  Copyright (c) 2013
 *
 * @FileName		: ProcessedProductProdAndScratchAction.java
 * @PageName		: 
 * @Date			: 오후 4:40:57
 * @LastModifier	: 최경민
 * @LastModifyDate	: 
 * @LastModifier	: 
 * Change history	:
 */
package com.pulp.production.action;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.opensymphony.xwork2.ActionSupport;
import com.pulp.production.service.ProductionInfoService;

/**
 * @author 최경민
 *
 */
public class ProcessedProductProdAndScratchAction extends ActionSupport {
	private static final long serialVersionUID = 435380073801028099L;
	private String REQUEST_RESULT = "ok";
	static Logger logger = Logger.getLogger(CombinedPaperTeamAction.class);

	private String errorCode = "";
	private List processedProductProdAndScratchYearList = null;
	private List processedProductProdAndScratchMonthList = null;
	private List processedProductProdAndScratchDateList = null;
	/**
	 * @return the rEQUEST_RESULT
	 */
	public String getREQUEST_RESULT() {
		return REQUEST_RESULT;
	}
	/**
	 * @param rEQUEST_RESULT the rEQUEST_RESULT to set
	 */
	public void setREQUEST_RESULT(String rEQUEST_RESULT) {
		REQUEST_RESULT = rEQUEST_RESULT;
	}
	/**
	 * @return the logger
	 */
	public static Logger getLogger() {
		return logger;
	}
	/**
	 * @param logger the logger to set
	 */
	public static void setLogger(Logger logger) {
		ProcessedProductProdAndScratchAction.logger = logger;
	}
	/**
	 * @return the errorCode
	 */
	public String getErrorCode() {
		return errorCode;
	}
	/**
	 * @param errorCode the errorCode to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}
	/**
	 * @return the processedProductProdAndScratchYearList
	 */
	public List getProcessedProductProdAndScratchYearList() {
		return processedProductProdAndScratchYearList;
	}
	/**
	 * @param processedProductProdAndScratchYearList the processedProductProdAndScratchYearList to set
	 */
	public void setProcessedProductProdAndScratchYearList(List processedProductProdAndScratchYearList) {
		this.processedProductProdAndScratchYearList = processedProductProdAndScratchYearList;
	}
	/**
	 * @return the processedProductProdAndScratchMonthList
	 */
	public List getProcessedProductProdAndScratchMonthList() {
		return processedProductProdAndScratchMonthList;
	}
	/**
	 * @param processedProductProdAndScratchMonthList the processedProductProdAndScratchMonthList to set
	 */
	public void setProcessedProductProdAndScratchMonthList(List processedProductProdAndScratchMonthList) {
		this.processedProductProdAndScratchMonthList = processedProductProdAndScratchMonthList;
	}
	/**
	 * @return the processedProductProdAndScratchDateList
	 */
	public List getProcessedProductProdAndScratchDateList() {
		return processedProductProdAndScratchDateList;
	}
	/**
	 * @param processedProductProdAndScratchDateList the processedProductProdAndScratchDateList to set
	 */
	public void setProcessedProductProdAndScratchDateList(List processedProductProdAndScratchDateList) {
		this.processedProductProdAndScratchDateList = processedProductProdAndScratchDateList;
	}

	public String execute() throws Exception{
		
		try {
			HttpServletRequest request = (HttpServletRequest) ServletActionContext.getRequest();

			ServletContext servletContext = ServletActionContext.getServletContext();
			WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(servletContext);
			ProductionInfoService productionInfoService = (ProductionInfoService) wac.getBean("productionInfoService");
			processedProductProdAndScratchYearList = productionInfoService.getProcessedProductProdAndScratchYear();
			processedProductProdAndScratchMonthList = productionInfoService.getProcessedProductProdAndScratchMonth();
			processedProductProdAndScratchDateList = productionInfoService.getProcessedProductProdAndScratchDate();

			request.setAttribute("processedProductProdAndScratchYearList", processedProductProdAndScratchYearList);
			request.setAttribute("processedProductProdAndScratchMonthList", processedProductProdAndScratchMonthList);
			request.setAttribute("processedProductProdAndScratchDateList", processedProductProdAndScratchDateList);
			
		} catch (Exception e) {
			REQUEST_RESULT = "FAILED";
			e.printStackTrace();
		}
		return REQUEST_RESULT;
	}
}
